home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / benchmarks / itc / sas / parser.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-08-30  |  26.8 KB  |  899 lines

  1. # define LSHIFT 257
  2. # define RSHIFT 258
  3. # define EOLN 259
  4. # define ID 260
  5. # define WORDID 261
  6. # define INTCONST 262
  7. # define FLOATCONST 263
  8. # define STRINGCONST 264
  9. # define CONDITION 265
  10. # define INTREG 266
  11. # define FLOATREG 267
  12. # define SPECIALREG 268
  13. # define CACHEREG 269
  14. # define CACHEOP 270
  15. # define TEMPLABEL 271
  16. # define FWDTEMPREF 272
  17. # define BCKWDTEMPREF 273
  18. # define FWDNUMTEMPREF 274
  19. # define BCKWDNUMTEMPREF 275
  20. # define rrx_form 276
  21. # define rrr_form 277
  22. # define rr0_form 278
  23. # define r2r_form 279
  24. # define r00_form 280
  25. # define zzz_form 281
  26. # define r0f_form 282
  27. # define r0f_form_reverse 283
  28. # define frx_form 284
  29. # define fff_form 285
  30. # define ff0_form 286
  31. # define fstore_form 287
  32. # define ff_cmp_form 288
  33. # define zrx_form 289
  34. # define zzx_form 290
  35. # define store_form 291
  36. # define r_store_form 292
  37. # define rx_cmp_form 293
  38. # define cmp_tag_form 294
  39. # define rx_cmp_trap_form 295
  40. # define cmp_tag_trap_form 296
  41. # define jump_form 297
  42. # define external_form 298
  43. # define external_store_form 299
  44. # define undef_form 300
  45. # define _globl 301
  46. # define _extern 302
  47. # define _long 303
  48. # define _word 304
  49. # define _byte 305
  50. # define _single 306
  51. # define _double 307
  52. # define _ascii 308
  53. # define _asciz 309
  54. # define _align 310
  55. # define _comm 311
  56. # define _lcomm 312
  57. # define _scomm 313
  58. # define _slcomm 314
  59. # define _text0 315
  60. # define _text1 316
  61. # define _text2 317
  62. # define _data0 318
  63. # define _data1 319
  64. # define _data2 320
  65. # define _sdata0 321
  66. # define _sdata1 322
  67. # define _set 323
  68. # define _org 324
  69. # define _space 325
  70. # define _stabs 326
  71. # define _stabn 327
  72. # define _stabd 328
  73.  
  74. # line 23 "parser.y"
  75. #include <stdio.h>
  76. #include <sys/file.h>
  77. #include "sas.h"
  78. #include "a.out.h"
  79.  
  80. static char *rcsid = 
  81.     "$Header: parser.y,v 3.9 88/10/18 16:34:17 hilfingr Exp $";
  82.  
  83. static struct _operandType 
  84.      _r0 = { REG, 0 };
  85.  
  86. static int list_oper;
  87.         /* Indicates bytes of data expected in list. */
  88.  
  89. int currentSegment;        /* Current region number into which 
  90.                  * instructions are being assembled.  Possible
  91.                  * values in #defines just above. */
  92.  
  93. bool haveWarnedAboutRegStores = FALSE;
  94.  
  95. # line 44 "parser.y"
  96. typedef union  {
  97.     unsigned int    num;
  98.     struct { char *str; int len; }
  99.             string;
  100.     symbolType      *sym;
  101.         operandType    operand;
  102.     exprType    *expr;
  103. } YYSTYPE;
  104. #define yyclearin yychar = -1
  105. #define yyerrok yyerrflag = 0
  106. extern int yychar;
  107. extern short yyerrflag;
  108. #ifndef YYMAXDEPTH
  109. #define YYMAXDEPTH 150
  110. #endif
  111. YYSTYPE yylval, yyval;
  112. # define YYERRCODE 256
  113.  
  114. # line 416 "parser.y"
  115.  
  116.  
  117. #include <stdio.h>
  118.  
  119. int
  120. yyerror(s)
  121.      char *s;
  122. {
  123.     ErrorMsg "%s.", s EndMsg;
  124. }
  125.  
  126. void
  127. initParser()
  128. {
  129. }
  130.  
  131. short yyexca[] ={
  132. -1, 0,
  133.     0, 1,
  134.     -2, 3,
  135. -1, 1,
  136.     0, -1,
  137.     -2, 0,
  138. -1, 2,
  139.     0, 2,
  140.     -2, 5,
  141.     };
  142. # define YYNPROD 160
  143. # define YYLAST 594
  144. short yyact[]={
  145.  
  146.   15, 311,  93,  48,  50,  52,  56,  57,  58,  54,
  147.   55,  49,  51,  53,  62,  64,  59,  60,  61, 298,
  148.   63,  65,  66,  67,  68, 294, 125, 290, 103, 239,
  149.  124, 123, 122, 121,  91,  80,  79, 255, 134,  81,
  150.   15,  89,  87,  90, 296, 101,  86,  89, 105,  85,
  151.  101, 101, 105, 118, 101,  89,  84,  83,  82,  89,
  152.   73,  72,   7,  88,  96,  89, 151, 133, 129,  89,
  153.   99, 126, 316,  78,  95, 308, 307, 130, 130, 130,
  154.  107, 306, 109,  71,  15, 304, 303, 302, 278, 277,
  155.  276, 120, 158, 299, 275, 274, 148, 166, 159, 257,
  156.  144, 142,   9, 143, 273, 145, 272, 271, 270, 267,
  157.   46, 265, 264, 263,  69,  70, 262, 261, 260, 259,
  158.  258, 208, 217, 216, 215, 214, 213, 212, 266, 211,
  159.  210, 209, 207, 206, 205, 204,  92,  94, 203, 218,
  160.  219, 220, 221, 222, 131, 132, 135, 202, 201, 200,
  161.   97, 198, 150, 196, 195, 194, 193, 115, 192, 140,
  162.  116, 226, 139, 138, 137, 136,   5,  77,  76,  75,
  163.   74,   8,  13,  11,  47,  10,   6,   4, 167,   3,
  164.    2,   1, 149, 117, 127, 160, 141, 165, 153,   0,
  165.    0,   0,   0,   0,   0, 197,   0,   0,   0, 199,
  166.   14,  12,   0,  44,   0, 225,   0, 241, 241,  98,
  167.    0, 106,  45, 108,   0, 110, 111, 112, 113, 254,
  168.  114,   0, 119,   0,   0,   0,   0, 227,   0,   0,
  169.  235,   0, 238, 240, 244, 243,   0,   0,   0,   0,
  170.   14, 250,  16,  17,  18,  19,  20,  21,  22,  23,
  171.   24,  25,  26,  27,  28,  29,  30,  31,  32,  33,
  172.   34,  35,  36,  37,  38,  39,  40,  41,  42,  43,
  173.  241, 223, 224, 237, 100, 291, 291, 242, 104, 100,
  174.  100, 102, 104, 100,  14, 292, 228, 229, 230, 242,
  175.  128,   0, 256,   0, 286,   0,   0, 287, 301, 288,
  176.  289, 293,   0, 300, 297,   0, 310, 312, 313, 312,
  177.  314, 315, 152,   0, 161, 146, 147, 164,   0, 317,
  178.    0, 163, 162,   0, 154, 155, 156, 157, 168, 169,
  179.  170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
  180.  180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
  181.  190, 191, 279, 280, 281,   0, 231, 232,   0, 233,
  182.    0, 234,   0, 236, 245, 246, 268, 269,   0,   0,
  183.  247, 248, 249, 148, 251, 252, 253, 144, 142,   0,
  184.  143,   0, 145,   0,   0,   0,   0,   0,   0,   0,
  185.  305,   0,   0,   0,   0,   0, 309,   0,   0,   0,
  186.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  187.    0,   0,   0,   0,   0,   0,   0,   0,   0, 282,
  188.  283, 284,   0,   0,   0, 285,   0,   0,   0, 150,
  189.    0,   0,   0,   0,   0, 295,   0,   0, 295,   0,
  190.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  191.    0,   0,   0,   0,   0,   0,   0,   0,   0, 149,
  192.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  193.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  194.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  195.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  196.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  197.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  198.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  199.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  200.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  201.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  202.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  203.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  204.    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
  205.    0,   0, 146, 147 };
  206. short yypact[]={
  207.  
  208. -1000,-1000,-1000,-194,-194,-1000, -59, -19,-1000,-1000,
  209. -273, -19,  25,-1000,-1000,-1000,-199,-200,-1000,-1000,
  210. -1000,-1000,-1000,-228,-229,-223,-202,-203,-204,-211,
  211. -1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-214,  33,
  212.   33,-230,  33,  33,  16,   6,-1000, -19,  13,  15,
  213.   14,  15,  14,  15,  14,  14,  14,  14,-1000,  14,
  214.   17,  14,  15,-232,-233,-234,-235,-239,  29,-1000,
  215. -1000,-1000,-1000,-1000,  33,  33,  33,-225,-225,-1000,
  216. -1000,-1000, 121, 120, 119, 118, 115, 335,  52,-1000,
  217.  335, 114, 112, 335, 111,-1000,-1000,-1000, 110, 109,
  218. -1000,  33,-1000, 107,-1000,  33, 105, 104, 103,  94,
  219.   91,  90,  89,-1000,  88,-1000,-1000,-1000,  33,  87,
  220.   86,  85,  83,  82,  81,  80, 335,-1000,-1000,  79,
  221.  335,  79,  79,  78,-1000,  78,  33,  33,  33,  33,
  222.    5,  33,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,
  223. -1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,  33,-1000,
  224.   52,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,
  225. -1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,
  226. -1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,
  227. -1000,-1000,  33,  33,  33,  14,  14,-1000,  14,-1000,
  228.   14,  15,  13,  15,  11,  11,  17,  17, 335,  14,
  229.   14,  14,  15,  14,  14,  14,  33,-226, 335, 335,
  230.  335, 335, 335,-1000,-1000,  52,  58,-1000,  76,  75,
  231.   74,  73,  72,  69,  68,  67,  65,  65,  65,  64,
  232. -1000, 335,-1000,  63,-1000,-1000,-1000,  62,  60,  51,
  233.   50,  46,  45,  44, 335,-1000,-1000,-1000,  33,  33,
  234.   33,  17,  17,  17,  14,  15,-1000,  23,-1000,-1000,
  235.   15,  15,  19,  19,   8,  15,  33,   8,  33,  43,
  236.   42,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,-1000,
  237. -1000, 335,-1000,-1000,  41,-1000,  33,-1000,  37,-1000,
  238.   32,  31,  33,  33,  33,-1000,  33,  33,  33,  28,
  239.  335,-1000, 335,-1000, 335, 335,  33, 335 };
  240. short yypgo[]={
  241.  
  242.    0, 188, 187,  93, 186, 185, 157,  25, 160,  70,
  243.   28,   2,  66,  27,  19,   1, 184, 183, 181, 180,
  244.  179, 166, 177, 176, 102, 175, 174, 173, 172, 128,
  245.   29,  63, 170,  68, 169, 168, 167,  67,  73 };
  246. short yyr1[]={
  247.  
  248.    0,  18,  18,  20,  19,  22,  19,  21,  25,  21,
  249.   21,  21,  21,  24,  24,  23,  23,  28,  28,  28,
  250.   26,  26,  26,  26,  26,  26,  26,  26,  26,  26,
  251.   26,  26,  26,  26,  26,  26,  26,  26,  26,  26,
  252.   26,  26,  26,  26,  26,  26,  26,  26,   8,   8,
  253.   10,  10,   9,   6,   6,  14,  13,  13,   7,   7,
  254.   15,  17,  31,  31,  29,  29,  30,  30,  11,  11,
  255.   12,  12,  12,  12,  12,  12,  12,  12,  12,   1,
  256.    1,   1,   1,   1,   2,   2,   2,   2,   2,   2,
  257.    2,   2,   2,   2,   2,   2,   2,   2,   2,   2,
  258.    2,   2,   2,   2,   2,   2,   2,   2,   4,   4,
  259.    4,   4,   4,   4,   4,   4,   4,   5,   5,  16,
  260.   27,  27,  32,  27,  34,  27,  35,  27,  36,  27,
  261.   38,  27,  27,  27,  27,  27,  27,  27,  27,  27,
  262.   27,  27,  27,  27,  27,  27,  27,  27,  27,  27,
  263.   27,  27,  27,  27,  27,  33,  33,  37,  37,   3 };
  264. short yyr2[]={
  265.  
  266.    0,   0,   1,   0,   2,   0,   3,   2,   0,   4,
  267.    3,   3,   2,   1,   1,   0,   2,   2,   2,   2,
  268.    6,   6,   6,   6,   6,   5,   5,   5,   6,   4,
  269.    6,   4,   4,   2,   1,   4,   2,   6,   6,   8,
  270.    6,   8,   8,   8,   6,   6,   2,   2,   1,   2,
  271.    1,   2,   1,   1,   1,   1,   1,   1,   1,   2,
  272.    1,   2,   1,   0,   0,   2,   1,   1,   2,   4,
  273.    1,   1,   1,   1,   1,   1,   3,   1,   2,   1,
  274.    1,   1,   1,   1,   1,   1,   1,   1,   1,   1,
  275.    1,   1,   1,   1,   1,   1,   1,   1,   1,   1,
  276.    1,   1,   1,   1,   1,   1,   1,   1,   1,   1,
  277.    1,   1,   1,   1,   1,   1,   1,   1,   1,   1,
  278.    2,   2,   0,   3,   0,   3,   0,   3,   0,   3,
  279.    0,   3,   2,   2,   2,   4,   4,   4,   4,   1,
  280.    1,   1,   1,   1,   1,   1,   1,   4,   4,   4,
  281.    2,   2,  10,   8,   6,   1,   3,   1,   3,   1 };
  282. short yychk[]={
  283.  
  284. -1000, -18, -19, -20, -22, -21, -23, 256, -21, -24,
  285.  -25, -27, 260, -28, 259,  59, 301, 302, 303, 304,
  286.  305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
  287.  315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
  288.  325, 326, 327, 328, 262, 271, -24, -26, 276, 284,
  289.  277, 285, 278, 286, 282, 283, 279, 280, 281, 289,
  290.  290, 291, 287, 293, 288, 294, 295, 296, 297, -24,
  291.  -24,  58, 260, 260, -32, -34, -35, -36, -38, 264,
  292.  264, 262, 260, 260, 260, 260, 260, -11, -31,  36,
  293.  -11, 264,  -3, -11,  -3,  58,  58, -24,  -8,  -9,
  294.  266,  37, 268, -10, 267,  37,  -8, -10,  -8, -10,
  295.   -8,  -8,  -8,  -8,  -8,  -6,  -8, -17,  36,  -8,
  296.  -10, 265, 265, 265, 265, 265, -11, -16, 261, -33,
  297.  -11, -33, -33, -37, 263, -37,  44,  44,  44,  44,
  298.   44,  -4,  43,  45,  42,  47, 257, 258,  38, 124,
  299.   94, -12, 260,  -1, 272, 273, 274, 275,  40,  46,
  300.   -5, 262, 270, 269, 265,  -2,  45, 126, 276, 277,
  301.  278, 279, 280, 281, 282, 283, 284, 285, 286, 287,
  302.  288, 289, 290, 291, 292, 293, 294, 295, 296, 297,
  303.  298, 299,  44,  44,  44,  44,  44,  -3,  44,  -3,
  304.   44,  44,  44,  44,  44,  44,  44,  44, -11,  44,
  305.   44,  44,  44,  44,  44,  44,  44,  44, -11, -11,
  306.  -11, -11, -11, 266, 267, -31, -11, -12,  -3,  -3,
  307.   -3,  -8,  -8,  -8,  -8, -10,  -8,  -9, -10, -30,
  308.  -10, -11, 266, -30, -10,  -6,  -6,  -8,  -8,  -8,
  309.  -10,  -8,  -8,  -8, -11, 263, -12,  41,  44,  44,
  310.   44,  44,  44,  44,  44,  44, -29,  44, -29, -29,
  311.   44,  44,  44,  44,  44,  44,  44,  44,  44,  -3,
  312.   -3,  -3,  -6,  -6,  -6,  -8, -10, -30, -10, -10,
  313.  -13, -11, 266, -13,  -7,  -8,  36, -10, -14,  -3,
  314.   -7, -14,  44,  44,  44,  -3,  44,  44,  44,  -3,
  315.  -11, -15, -11, -15, -11, -11,  44, -11 };
  316. short yydef[]={
  317.  
  318.   -2,  -2,  -2,  15,  15,   4,   8,   0,   6,   7,
  319.    0,   0,   0,  16,  13,  14,   0,   0, 122, 124,
  320.  126, 128, 130,   0,   0,   0,   0,   0,   0,   0,
  321.  139, 140, 141, 142, 143, 144, 145, 146,   0,  63,
  322.   63,   0,  63,  63,   0,   0,  12,   0,   0,   0,
  323.    0,   0,   0,   0,   0,   0,   0,   0,  34,   0,
  324.    0,   0,   0,   0,   0,   0,   0,   0,  63,  10,
  325.   11,  17, 120, 121,  63,  63,  63,   0,   0, 132,
  326.  133, 134,   0,   0,   0,   0,   0, 150,   0,  62,
  327.  151,   0,   0, 159,   0,  18,  19,   9,   0,   0,
  328.   48,  63,  52,   0,  50,  63,   0,   0,   0,   0,
  329.    0,   0,   0,  33,   0,  36,  53,  54,  63,   0,
  330.    0,   0,   0,   0,   0,   0,  46,  47, 119, 123,
  331.  155, 125, 127, 129, 157, 131,  63,  63,  63,  63,
  332.   63,  63, 108, 109, 110, 111, 112, 113, 114, 115,
  333.  116,  68,  70,  71,  72,  73,  74,  75,  63,  77,
  334.    0,  79,  80,  81,  82,  83, 117, 118,  84,  85,
  335.   86,  87,  88,  89,  90,  91,  92,  93,  94,  95,
  336.   96,  97,  98,  99, 100, 101, 102, 103, 104, 105,
  337.  106, 107,  63,  63,  63,   0,   0,  49,   0,  51,
  338.    0,   0,   0,   0,  63,  63,   0,   0,  61,   0,
  339.    0,   0,   0,   0,   0,   0,  63,   0, 135, 136,
  340.  137, 138, 147, 148, 149,   0,   0,  78,   0,   0,
  341.    0,   0,   0,   0,   0,   0,  64,  64,  64,   0,
  342.   29,  66,  67,   0,  31,  32,  35,   0,   0,   0,
  343.    0,   0,   0,   0, 156, 158,  69,  76,  63,  63,
  344.   63,   0,   0,   0,   0,   0,  25,  63,  26,  27,
  345.    0,   0,  63,  63,   0,   0,  63,   0,  63,   0,
  346.    0, 154,  20,  21,  22,  23,  24,  65,  28,  30,
  347.   37,  56,  57,  38,   0,  58,  63,  40,   0,  55,
  348.   44,  45,  63,  63,  63,  59,  63,  63,  63,   0,
  349.  153,  39,  60,  41,  42,  43,  63, 152 };
  350. #ifndef lint
  351. static char yaccpar_sccsid[] = "@(#)yaccpar    4.1    (Berkeley)    2/11/83";
  352. #endif not lint
  353.  
  354. #
  355. # define YYFLAG -1000
  356. # define YYERROR goto yyerrlab
  357. # define YYACCEPT return(0)
  358. # define YYABORT return(1)
  359.  
  360. /*    parser for yacc output    */
  361.  
  362. #ifdef YYDEBUG
  363. int yydebug = 0; /* 1 for debugging */
  364. #endif
  365. YYSTYPE yyv[YYMAXDEPTH]; /* where the values are stored */
  366. int yychar = -1; /* current input token number */
  367. int yynerrs = 0;  /* number of errors */
  368. short yyerrflag = 0;  /* error recovery flag */
  369.  
  370. yyparse() {
  371.  
  372.     short yys[YYMAXDEPTH];
  373.     short yyj, yym;
  374.     register YYSTYPE *yypvt;
  375.     register short yystate, *yyps, yyn;
  376.     register YYSTYPE *yypv;
  377.     register short *yyxi;
  378.  
  379.     yystate = 0;
  380.     yychar = -1;
  381.     yynerrs = 0;
  382.     yyerrflag = 0;
  383.     yyps= &yys[-1];
  384.     yypv= &yyv[-1];
  385.  
  386.  yystack:    /* put a state and value onto the stack */
  387.  
  388. #ifdef YYDEBUG
  389.     if( yydebug  ) printf( "state %d, char 0%o\n", yystate, yychar );
  390. #endif
  391.         if( ++yyps> &yys[YYMAXDEPTH] ) { yyerror( "yacc stack overflow" ); return(1); }
  392.         *yyps = yystate;
  393.         ++yypv;
  394.         *yypv = yyval;
  395.  
  396.  yynewstate:
  397.  
  398.     yyn = yypact[yystate];
  399.  
  400.     if( yyn<= YYFLAG ) goto yydefault; /* simple state */
  401.  
  402.     if( yychar<0 ) if( (yychar=yylex())<0 ) yychar=0;
  403.     if( (yyn += yychar)<0 || yyn >= YYLAST ) goto yydefault;
  404.  
  405.     if( yychk[ yyn=yyact[ yyn ] ] == yychar ){ /* valid shift */
  406.         yychar = -1;
  407.         yyval = yylval;
  408.         yystate = yyn;
  409.         if( yyerrflag > 0 ) --yyerrflag;
  410.         goto yystack;
  411.         }
  412.  
  413.  yydefault:
  414.     /* default state action */
  415.  
  416.     if( (yyn=yydef[yystate]) == -2 ) {
  417.         if( yychar<0 ) if( (yychar=yylex())<0 ) yychar = 0;
  418.         /* look through exception table */
  419.  
  420.         for( yyxi=yyexca; (*yyxi!= (-1)) || (yyxi[1]!=yystate) ; yyxi += 2 ) ; /* VOID */
  421.  
  422.         while( *(yyxi+=2) >= 0 ){
  423.             if( *yyxi == yychar ) break;
  424.             }
  425.         if( (yyn = yyxi[1]) < 0 ) return(0);   /* accept */
  426.         }
  427.  
  428.     if( yyn == 0 ){ /* error */
  429.         /* error ... attempt to resume parsing */
  430.  
  431.         switch( yyerrflag ){
  432.  
  433.         case 0:   /* brand new error */
  434.  
  435.             yyerror( "syntax error" );
  436.         yyerrlab:
  437.             ++yynerrs;
  438.  
  439.         case 1:
  440.         case 2: /* incompletely recovered error ... try again */
  441.  
  442.             yyerrflag = 3;
  443.  
  444.             /* find a state where "error" is a legal shift action */
  445.  
  446.             while ( yyps >= yys ) {
  447.                yyn = yypact[*yyps] + YYERRCODE;
  448.                if( yyn>= 0 && yyn < YYLAST && yychk[yyact[yyn]] == YYERRCODE ){
  449.                   yystate = yyact[yyn];  /* simulate a shift of "error" */
  450.                   goto yystack;
  451.                   }
  452.                yyn = yypact[*yyps];
  453.  
  454.                /* the current yyps has no shift onn "error", pop stack */
  455.  
  456. #ifdef YYDEBUG
  457.                if( yydebug ) printf( "error recovery pops state %d, uncovers %d\n", *yyps, yyps[-1] );
  458. #endif
  459.                --yyps;
  460.                --yypv;
  461.                }
  462.  
  463.             /* there is no state on the stack with an error shift ... abort */
  464.  
  465.     yyabort:
  466.             return(1);
  467.  
  468.  
  469.         case 3:  /* no shift yet; clobber input char */
  470.  
  471. #ifdef YYDEBUG
  472.             if( yydebug ) printf( "error recovery discards char %d\n", yychar );
  473. #endif
  474.  
  475.             if( yychar == 0 ) goto yyabort; /* don't discard EOF, quit */
  476.             yychar = -1;
  477.             goto yynewstate;   /* try again in the same state */
  478.  
  479.             }
  480.  
  481.         }
  482.  
  483.     /* reduction by production yyn */
  484.  
  485. #ifdef YYDEBUG
  486.         if( yydebug ) printf("reduce %d\n",yyn);
  487. #endif
  488.         yyps -= yyr2[yyn];
  489.         yypvt = yypv;
  490.         yypv -= yyr2[yyn];
  491.         yyval = yypv[1];
  492.         yym=yyn;
  493.             /* consult goto table to find next state */
  494.         yyn = yyr1[yyn];
  495.         yyj = yypgo[yyn] + *yyps + 1;
  496.         if( yyj>=YYLAST || yychk[ yystate = yyact[yyj] ] != -yyn ) yystate = yyact[yypgo[yyn]];
  497.         switch(yym){
  498.             
  499. case 3:
  500. # line 88 "parser.y"
  501. { initExprs(); } break;
  502. case 4:
  503. # line 88 "parser.y"
  504. { } break;
  505. case 5:
  506. # line 89 "parser.y"
  507. { initExprs(); } break;
  508. case 6:
  509. # line 90 "parser.y"
  510. { } break;
  511. case 7:
  512. # line 94 "parser.y"
  513. { } break;
  514. case 8:
  515. # line 95 "parser.y"
  516. { setAlignment(2); } break;
  517. case 9:
  518. # line 95 "parser.y"
  519. { } break;
  520. case 10:
  521. # line 96 "parser.y"
  522. { } break;
  523. case 11:
  524. # line 98 "parser.y"
  525. { ErrorMsg "Unknown or missing command." EndMsg; } break;
  526. case 12:
  527. # line 99 "parser.y"
  528. { } break;
  529. case 13:
  530. # line 103 "parser.y"
  531. { } break;
  532. case 14:
  533. # line 104 "parser.y"
  534. { } break;
  535. case 15:
  536. # line 108 "parser.y"
  537. { } break;
  538. case 16:
  539. # line 109 "parser.y"
  540. { } break;
  541. case 17:
  542. # line 113 "parser.y"
  543. { DefineLabel(yypvt[-1].sym); } break;
  544. case 18:
  545. # line 114 "parser.y"
  546. { DefineTempLabel((int) yypvt[-1].num, (symbolType *) NULL); } break;
  547. case 19:
  548. # line 115 "parser.y"
  549. { DefineTempLabel(-1, yypvt[-1].sym); } break;
  550. case 20:
  551. # line 120 "parser.y"
  552. { emitRRxInst(yypvt[-5].num, yypvt[-4].operand, yypvt[-2].operand, yypvt[-0].operand); } break;
  553. case 21:
  554. # line 122 "parser.y"
  555. { emitRRxInst(yypvt[-5].num, yypvt[-4].operand, yypvt[-2].operand, yypvt[-0].operand); } break;
  556. case 22:
  557. # line 124 "parser.y"
  558. { emitRRxInst(yypvt[-5].num, yypvt[-4].operand, yypvt[-2].operand, yypvt[-0].operand); } break;
  559. case 23:
  560. # line 126 "parser.y"
  561. { emitRRxInst(yypvt[-5].num, yypvt[-4].operand, yypvt[-2].operand, yypvt[-0].operand); } break;
  562. case 24:
  563. # line 128 "parser.y"
  564. { emitRRxInst(yypvt[-5].num, yypvt[-4].operand, yypvt[-2].operand, yypvt[-0].operand); } break;
  565. case 25:
  566. # line 130 "parser.y"
  567. { emitRRxInst(yypvt[-4].num, yypvt[-3].operand, yypvt[-1].operand, _r0); } break;
  568. case 26:
  569. # line 132 "parser.y"
  570. { emitRRxInst(yypvt[-4].num, yypvt[-3].operand, yypvt[-1].operand, _r0); } break;
  571. case 27:
  572. # line 134 "parser.y"
  573. { emitRRxInst(yypvt[-4].num, yypvt[-3].operand, yypvt[-1].operand, _r0); } break;
  574. case 28:
  575. # line 136 "parser.y"
  576. { emitRRxInst(yypvt[-5].num, yypvt[-4].operand, _r0, yypvt[-0].operand); } break;
  577. case 29:
  578. # line 138 "parser.y"
  579. { emitRRxInst(yypvt[-3].num, yypvt[-2].operand, _r0, yypvt[-0].operand); } break;
  580. case 30:
  581. # line 141 "parser.y"
  582. { emitRRxInst(yypvt[-5].num, yypvt[-0].operand, _r0, yypvt[-4].operand); } break;
  583. case 31:
  584. # line 144 "parser.y"
  585. { emitRRxInst(yypvt[-3].num, yypvt[-0].operand, _r0, yypvt[-2].operand); } break;
  586. case 32:
  587. # line 146 "parser.y"
  588. { emitRRxInst(yypvt[-3].num, yypvt[-2].operand, yypvt[-2].operand, yypvt[-0].operand); } break;
  589. case 33:
  590. # line 148 "parser.y"
  591. { emitRRxInst(yypvt[-1].num, yypvt[-0].operand, _r0, _r0); } break;
  592. case 34:
  593. # line 150 "parser.y"
  594. { emitRRxInst(yypvt[-0].num, _r0, _r0, _r0); } break;
  595. case 35:
  596. # line 152 "parser.y"
  597. { emitRRxInst(yypvt[-3].num, _r0, yypvt[-2].operand, yypvt[-0].operand); } break;
  598. case 36:
  599. # line 153 "parser.y"
  600. { emitRRxInst(yypvt[-1].num, _r0, _r0, yypvt[-0].operand); } break;
  601. case 37:
  602. # line 155 "parser.y"
  603. { emitStoreInst(yypvt[-5].num, yypvt[-4].operand, yypvt[-2].operand, yypvt[-0].expr); } break;
  604. case 38:
  605. # line 157 "parser.y"
  606. { emitStoreInst(yypvt[-5].num, yypvt[-4].operand, yypvt[-2].operand, yypvt[-0].expr); } break;
  607. case 39:
  608. # line 159 "parser.y"
  609. { emitRxCmpInst(yypvt[-7].num, yypvt[-6].num, yypvt[-4].operand, yypvt[-2].operand, yypvt[-0].expr, FALSE); } break;
  610. case 40:
  611. # line 161 "parser.y"
  612. { emitRxCmpInst(yypvt[-5].num, yypvt[-4].num, yypvt[-2].operand, yypvt[-0].operand, nullExpr, FALSE); } break;
  613. case 41:
  614. # line 163 "parser.y"
  615. { emitCmpTagInst(yypvt[-7].num, yypvt[-6].num, yypvt[-4].operand, yypvt[-2].expr, yypvt[-0].expr, FALSE); } break;
  616. case 42:
  617. # line 165 "parser.y"
  618. { emitRxCmpInst(yypvt[-7].num, yypvt[-6].num, yypvt[-4].operand, yypvt[-2].operand, yypvt[-0].expr, TRUE); } break;
  619. case 43:
  620. # line 167 "parser.y"
  621. { emitCmpTagInst(yypvt[-7].num, yypvt[-6].num, yypvt[-4].operand, yypvt[-2].expr, yypvt[-0].expr, TRUE); } break;
  622. case 44:
  623. # line 169 "parser.y"
  624. { emitRxCmpInst(yypvt[-5].num, yypvt[-4].num, yypvt[-2].operand, yypvt[-0].operand, nullExpr, TRUE); } break;
  625. case 45:
  626. # line 171 "parser.y"
  627. { emitCmpTagInst(yypvt[-5].num, yypvt[-4].num, yypvt[-2].operand, yypvt[-0].expr, nullExpr, TRUE); } break;
  628. case 46:
  629. # line 172 "parser.y"
  630. { emitJumpInst(yypvt[-1].num, yypvt[-0].expr); } break;
  631. case 47:
  632. # line 173 "parser.y"
  633. { emitJumpInst(yypvt[-1].num, yypvt[-0].expr); } break;
  634. case 48:
  635. # line 177 "parser.y"
  636. { yyval.operand.type = REG; yyval.operand.number = yypvt[-0].num; } break;
  637. case 49:
  638. # line 178 "parser.y"
  639. { if (yypvt[-0].num > LASTINTREG) {
  640.                       yyval.operand.number = 0;
  641.                       ErrorMsg 
  642.                      "Integer register number %d out of range.",
  643.                      yypvt[-0].num
  644.                       EndMsg;
  645.                   }
  646.                   else yyval.operand.number = yypvt[-0].num;
  647.                   yyval.operand.type = REG;
  648.                 } break;
  649. case 50:
  650. # line 191 "parser.y"
  651. { yyval.operand.type = REG;  yyval.operand.number = yypvt[-0].num; } break;
  652. case 51:
  653. # line 192 "parser.y"
  654. { if (yypvt[-0].num > LASTFLOATREG) {
  655.                       yyval.operand.number = 0;
  656.                       ErrorMsg
  657.                       "Floating point register number %d out of range.",
  658.                       yypvt[-0].num
  659.                       EndMsg;
  660.                       }
  661.                   else yyval.operand.number = yypvt[-0].num;
  662.                   yyval.operand.type = REG;
  663.                   } break;
  664. case 52:
  665. # line 205 "parser.y"
  666. { yyval.operand.type = REG; yyval.operand.number = yypvt[-0].num; } break;
  667. case 54:
  668. # line 210 "parser.y"
  669. { yyval.operand.type = IMMED;
  670.                   yyval.operand.expr = yypvt[-0].expr; } break;
  671. case 55:
  672. # line 216 "parser.y"
  673. { yyval.expr = numToExpr(yypvt[-0].num); } break;
  674. case 57:
  675. # line 221 "parser.y"
  676. { yyval.expr = numToExpr(yypvt[-0].num);
  677.                   if (! haveWarnedAboutRegStores) {
  678.                       haveWarnedAboutRegStores = TRUE;
  679.                       WarningMsg 
  680.                       "Warning: at least one store with three register operands."
  681.                       EndMsg;
  682.                   }
  683.                   } break;
  684. case 59:
  685. # line 233 "parser.y"
  686. { yyval.operand.type = IMMED;
  687.                   yyval.operand.expr = numToExpr(yypvt[-0].num); } break;
  688. case 61:
  689. # line 242 "parser.y"
  690. { yyval.expr = yypvt[-0].expr; } break;
  691. case 62:
  692. # line 246 "parser.y"
  693. { } break;
  694. case 63:
  695. # line 247 "parser.y"
  696. { } break;
  697. case 64:
  698. # line 251 "parser.y"
  699. { } break;
  700. case 65:
  701. # line 252 "parser.y"
  702. { } break;
  703. case 66:
  704. # line 256 "parser.y"
  705. { if (yypvt[-0].expr -> class != MANIFEST_INT ||
  706.                       yypvt[-0].expr -> v.value != 0) {
  707.                       ErrorMsg "Operand must be 0." EndMsg;
  708.                   }
  709.                 } break;
  710. case 67:
  711. # line 261 "parser.y"
  712. { if (yypvt[-0].num != 0) {
  713.                       ErrorMsg "Operand must be 0." EndMsg;
  714.                       }
  715.                 } break;
  716. case 68:
  717. # line 268 "parser.y"
  718. { yyval.expr = yypvt[-0].expr; } break;
  719. case 69:
  720. # line 269 "parser.y"
  721. { yyval.expr = consBinaryExpr(yypvt[-2].num, yypvt[-3].expr, yypvt[-0].expr); } break;
  722. case 70:
  723. # line 273 "parser.y"
  724. { yyval.expr = symToExpr(yypvt[-0].sym); } break;
  725. case 71:
  726. # line 274 "parser.y"
  727. { yyval.expr = numToExpr(yypvt[-0].num); } break;
  728. case 72:
  729. # line 275 "parser.y"
  730. { yyval.expr = fwdTempLabelToExpr(-1, yypvt[-0].sym); } break;
  731. case 73:
  732. # line 276 "parser.y"
  733. { yyval.expr = bckwdTempLabelToExpr(-1, yypvt[-0].sym); } break;
  734. case 74:
  735. # line 277 "parser.y"
  736. { yyval.expr = fwdTempLabelToExpr((int) yypvt[-0].num,
  737.                                 (symbolType *) NULL); } break;
  738. case 75:
  739. # line 279 "parser.y"
  740. { yyval.expr = bckwdTempLabelToExpr((int) yypvt[-0].num,
  741.                             (symbolType *) NULL);
  742.                     } break;
  743. case 76:
  744. # line 282 "parser.y"
  745. { yyval.expr = yypvt[-1].expr; } break;
  746. case 77:
  747. # line 283 "parser.y"
  748. { yyval.expr = pointExpr(); } break;
  749. case 78:
  750. # line 284 "parser.y"
  751. { yyval.expr = consUnaryExpr(yypvt[-1].num, yypvt[-0].expr); } break;
  752. case 83:
  753. # line 292 "parser.y"
  754. { yyval.num = yypvt[-0].num & ~instModifierBits; } break;
  755. case 117:
  756. # line 335 "parser.y"
  757. { yyval.num = '-'; } break;
  758. case 118:
  759. # line 336 "parser.y"
  760. { yyval.num = '~'; } break;
  761. case 119:
  762. # line 341 "parser.y"
  763. { yyval.expr = symToExpr(yypvt[-0].sym); } break;
  764. case 120:
  765. # line 345 "parser.y"
  766. { setGlobalSym(yypvt[-0].sym); } break;
  767. case 121:
  768. # line 346 "parser.y"
  769. { setGlobalSym(yypvt[-0].sym); } break;
  770. case 122:
  771. # line 347 "parser.y"
  772. { list_oper = LONG; setAlignment(2); } break;
  773. case 123:
  774. # line 348 "parser.y"
  775. { } break;
  776. case 124:
  777. # line 349 "parser.y"
  778. { list_oper = WORD; setAlignment(1); } break;
  779. case 125:
  780. # line 350 "parser.y"
  781. { } break;
  782. case 126:
  783. # line 351 "parser.y"
  784. { list_oper = BYTE; } break;
  785. case 127:
  786. # line 352 "parser.y"
  787. { } break;
  788. case 128:
  789. # line 353 "parser.y"
  790. { list_oper = SINGLE; setAlignment(2); } break;
  791. case 129:
  792. # line 354 "parser.y"
  793. { } break;
  794. case 130:
  795. # line 355 "parser.y"
  796. { list_oper = DOUBLE; setAlignment(3); } break;
  797. case 131:
  798. # line 356 "parser.y"
  799. { } break;
  800. case 132:
  801. # line 357 "parser.y"
  802. { emitBytes(yypvt[-0].string.str, yypvt[-0].string.len); } break;
  803. case 133:
  804. # line 358 "parser.y"
  805. { emitBytes(yypvt[-0].string.str, yypvt[-0].string.len);
  806.                             emitBytes((char *) "\0", 1); } break;
  807. case 134:
  808. # line 360 "parser.y"
  809. { setAlignment(yypvt[-0].num); } break;
  810. case 135:
  811. # line 361 "parser.y"
  812. { setSymCommDefn(yypvt[-2].sym, yypvt[-0].expr, FALSE); } break;
  813. case 136:
  814. # line 362 "parser.y"
  815. { setSymLcommDefn(yypvt[-2].sym, yypvt[-0].expr, FALSE); } break;
  816. case 137:
  817. # line 363 "parser.y"
  818. { setSymCommDefn(yypvt[-2].sym, yypvt[-0].expr, TRUE); } break;
  819. case 138:
  820. # line 364 "parser.y"
  821. { setSymLcommDefn(yypvt[-2].sym, yypvt[-0].expr, TRUE); } break;
  822. case 139:
  823. # line 365 "parser.y"
  824. { currentSegment = RP_SEG0; } break;
  825. case 140:
  826. # line 366 "parser.y"
  827. { currentSegment = RP_SEG0+1; } break;
  828. case 141:
  829. # line 367 "parser.y"
  830. { currentSegment = RP_SEG0+2; } break;
  831. case 142:
  832. # line 368 "parser.y"
  833. { currentSegment = RP_SEG0+3; } break;
  834. case 143:
  835. # line 369 "parser.y"
  836. { currentSegment = RP_SEG0+4; } break;
  837. case 144:
  838. # line 370 "parser.y"
  839. { currentSegment = RP_SEG0+5; } break;
  840. case 145:
  841. # line 371 "parser.y"
  842. { currentSegment = RP_SEG0+7; } break;
  843. case 146:
  844. # line 372 "parser.y"
  845. { currentSegment = RP_SEG0+8; } break;
  846. case 147:
  847. # line 373 "parser.y"
  848. { setSymDefn(yypvt[-2].sym, yypvt[-0].expr); } break;
  849. case 148:
  850. # line 374 "parser.y"
  851. { setSymDefn(yypvt[-2].sym, numToExpr(yypvt[-0].num)); } break;
  852. case 149:
  853. # line 375 "parser.y"
  854. { setSymDefn(yypvt[-2].sym, numToExpr(yypvt[-0].num)); } break;
  855. case 150:
  856. # line 376 "parser.y"
  857. { SetOrg(yypvt[-0].expr); } break;
  858. case 151:
  859. # line 377 "parser.y"
  860. { leaveSpace(yypvt[-0].expr); } break;
  861. case 152:
  862. # line 380 "parser.y"
  863. { emitStab(yypvt[-8].string.str, yypvt[-6].num, yypvt[-4].num, yypvt[-2].num, yypvt[-0].expr); } break;
  864. case 153:
  865. # line 383 "parser.y"
  866. { emitStab((char *) "", 
  867.                            yypvt[-6].num, yypvt[-4].num, yypvt[-2].num, yypvt[-0].expr); } break;
  868. case 154:
  869. # line 387 "parser.y"
  870. { emitStab((char *) "",
  871.                            yypvt[-4].num, yypvt[-2].num, yypvt[-0].num, 
  872.                            pointExpr()); } break;
  873. case 155:
  874. # line 394 "parser.y"
  875. { emitExpr(yypvt[-0].expr, list_oper); } break;
  876. case 156:
  877. # line 395 "parser.y"
  878. { emitExpr(yypvt[-0].expr, list_oper); } break;
  879. case 157:
  880. # line 399 "parser.y"
  881. { emitFloat(yypvt[-0].string.str, yypvt[-0].string.len, list_oper); } break;
  882. case 158:
  883. # line 401 "parser.y"
  884. { emitFloat(yypvt[-0].string.str, yypvt[-0].string.len, list_oper); } break;
  885. case 159:
  886. # line 406 "parser.y"
  887. { if (yypvt[-0].expr->class != MANIFEST_INT) {
  888.                               ErrorMsg
  889.                       "Expression must be static."
  890.                       EndMsg;
  891.                       yyval.num = 0;
  892.                   }
  893.                   else yyval.num = yypvt[-0].expr->v.value;
  894.                   } break;
  895.         }
  896.         goto yystack;  /* stack new state and value */
  897.  
  898.     }
  899.